package LuoGu.搜索.选数;

import java.util.Scanner;
//递归
public class Main {
    static int n;
    static int nn;
    static int [] temp;
    static int ans = 0;
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        n = s.nextInt();
        nn = s.nextInt();
        temp = new int [n];
        for(int i=0;i<n;i++){
            temp[i] = s.nextInt();
        }
        dfs(0,0,0);
        System.out.print(ans);
    }

    public static void dfs(int k,int start,int all){
        if(k==nn){
            if(prime(all)){
                ans++;
                return;
            }
        }
        for(int i=start;i<n;i++){
            //主要在start上，start记录的是下次搜索的范围
            dfs(k+1,i+1,all+temp[i]);
        }
    }

    public static boolean prime(int temp){
        for(int i=2;i*i<temp;i++){
            if(temp%i==0) return false;
        }
        return true;
    }
}
